﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using Xcj.Mes.DataBase.Interface;
using Xcj.Mes.WholeLine.DataBase.Common;

namespace Xcj.Mes.WholeLine.DataBase.Entity
{
    public class BaseEntity : IBaseEntity, INotifyPropertyChanged, ICloneable
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = "")//此处使用特性
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        private Int64 _id = 0;
        [Key]
        public Int64 ID { get => _id; set { _id = value; RaisePropertyChanged(); } }

        private DateTime _createTime = DateTime.Now;
        [Alias("修改时间")]
        public DateTime CreateTime { get => _createTime; set { _createTime = value; RaisePropertyChanged(); } }

        private bool _selected = false;
        [Alias("是否选择")]
        public bool Selected { get => _selected; set { _selected = value; RaisePropertyChanged(); } }

        private string _remarks = string.Empty;
        [Alias("备注"), StringLength(64)]
        public string Remarks { get => _remarks; set { _remarks = value?.Trim(); RaisePropertyChanged(); } }
    }
}
